home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.07.lha / AmiCAD / ARexx / Nomenclature.AmiCAD < prev    next >
Text File  |  2000-11-22  |  3KB  |  143 lines

  1. /* Nomenclature.AmiCAD
  2.    Version 1.00: 21 novembre 2000
  3.    $VER: Nomenclature.AmiCAD 1.00 (© R.Florac 21/11/2000)
  4.  */
  5.  
  6. options results     /* indispensable pour récupérer le résultat des macros */
  7.  
  8. signal on error     /* pour l'interception des erreurs */
  9. signal on syntax
  10.  
  11. port=address()
  12.  
  13. lf='0a'x
  14. 'OBJECTS'
  15. nbo=result
  16. if nbo<1 then do
  17.     'MESSAGE("Le document est vide !")'
  18.     exit
  19. end
  20.  
  21. nbc=0
  22. 'LOCK:TITLE("Recherche des composants...")'
  23. do i=1 to nbo
  24.     'TYPE('i')'     /* Composant ? */
  25.     if result=1 then do
  26.     'PARTNAME('i')'         /* Nom du composant ? */
  27.     comp=result
  28.     if comp~="ALIMENTATION" & comp~="MASSE" & comp~="MASSE2" & comp~="CONNEXION SIMPLE" & comp~="CONNEXION DOUBLE" & comp~="Flèche" then do
  29.         if comp="RÉSISTANCE" | left(comp,12)="CONDENSATEUR" then do
  30.         'GETVAL('i')'
  31.         valeur=result
  32.         if valeur>0 then do
  33.             'READTEXT('valeur')'
  34.             valeur=result
  35.             if right(valeur,1)='‹' then valeur=left(valeur,length(valeur)-1)
  36.             comp=comp||' '||valeur
  37.         end
  38.         end
  39.         else if left(comp,10)="TRANSISTOR" then do
  40.         'GETVAL('i')'
  41.         valeur=result
  42.         if valeur>0 then do
  43.             'READTEXT('valeur')'
  44.             comp="TRANSISTOR "||result
  45.         end
  46.         end
  47.         else if left(comp,5)="DIODE" then do
  48.         'GETVAL('i')'
  49.         valeur=result
  50.         if valeur>0 then do
  51.             'READTEXT('valeur')'
  52.             comp="DIODE "||result
  53.         end
  54.         end
  55.         else if left(comp,7)="BORNIER" then do
  56.         comp="BORNIER"
  57.         end
  58.         else if left(comp,13)="POTENTIOMÈTRE" then do
  59.         'GETVAL('i')'
  60.         valeur=result
  61.         if valeur>0 then do
  62.             'READTEXT('valeur')'
  63.             valeur=result
  64.             if right(valeur,1)='‹' then valeur=left(valeur,length(valeur)-1)
  65.             comp="POTENTIOMÈTRE "||valeur
  66.         end
  67.         end
  68.         else if left(comp,6)~="BOUTON" & left(comp,12)~="INTERRUPTEUR" & left(comp,7)~="CONTACT" then do
  69.         'GETVAL('i')'
  70.         valeur=result
  71.         if valeur>0 then do
  72.             'READTEXT('valeur')'
  73.             comp=result
  74.         end
  75.         end
  76.         nouveau=1
  77.         do j=0 to nbc
  78.         if comp.j=comp then do
  79.             nbcomp.j=nbcomp.j+1
  80.             nouveau=0
  81.             leave j
  82.         end
  83.         end
  84.         if nouveau=1 then do    /* Nouveau composant ? */
  85.         comp.nbc=comp
  86.         objet.nbc=i
  87.         nbcomp.nbc=1
  88.         nbc=nbc+1
  89.         end
  90.     end
  91.     end
  92. end
  93.  
  94. if nbc>0 then do
  95.     'TITLE("Traitement des données...")'
  96.     do i=0 to nbc-1            /* Calcul du nombre de circuits nécessaires */
  97.     'GETDEVS(PARTNAME('objet.i'))'
  98.     j=result
  99.     if j>0 then do
  100.         nbcomp.i=(nbcomp.i+j-1)%j
  101.     end
  102.     end
  103.     comps='"'
  104.     do i=0 to nbc-1
  105.     comps=comps||comp.i ':' nbcomp.i
  106.     if i<nbc-1 then comps=comps||lf
  107.     end
  108.     'TITLE(""):REQUEST("Sauver cette liste ?"+CHR(10)+'comps'")'
  109.     if result>0 then do
  110.     'REQFILE("Fichier nomenclature ?","Travail:Texte/ASCII",FILEPART("")+".Liste")'
  111.     fichier=result
  112.     if fichier~="" then do
  113.         'LOCK'
  114.         if ~open(file, fichier, 'W') then exit
  115.         do i=0 to nbc-1
  116.         writeln(file,comp.i||' : '||nbcomp.i)
  117.         end
  118.         close(file)
  119.         address command
  120.         'sort' '"'fichier'"' 'RAM:FichierTrié'
  121.         'copy' 'RAM:FichierTrié' '"'fichier'"'
  122.         'delete' 'RAM:FichierTrié'
  123.         address(port)
  124.         'MESSAGE("Sauvegarde terminée"):UNLOCK'
  125.     end
  126.     end
  127. end
  128. else 'MESSAGE("Aucun composant n''a été trouvé")'
  129. 'TITLE("")'
  130. exit
  131.  
  132. /* Traitement des erreurs, interruption du programme */
  133. syntax:
  134. erreur=RC
  135. address(port)
  136. 'MESSAGE("Script Nomenclature.AmiCAD"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  137. exit
  138.  
  139. error:
  140. address(port)
  141. 'MESSAGE("Script Nomenclature.AmiCAD"+CHR(10)+"Erreur en ligne 'SIGL'")'
  142. exit
  143.